package com.liesheng.haylou.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.liesheng.haylou.app.HyApplication;

public class NetworkUtil {
    public static boolean isNetworkEnabled() {
        ConnectivityManager manager = (ConnectivityManager) HyApplication.mApp
                .getSystemService(Context.CONNECTIVITY_SERVICE);


        NetworkInfo info = manager.getActiveNetworkInfo();
        if (info != null && info.isConnectedOrConnecting()) {
            return true;
        }
        return false;
    }

    public static boolean isUserMobileNetwork() {
        ConnectivityManager manager = (ConnectivityManager) HyApplication.mApp
                .getSystemService(Context.CONNECTIVITY_SERVICE);


        NetworkInfo info = manager.getActiveNetworkInfo();
        if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) {
            return true;
        }
        return false;
    }
}
